Skip to content

Add function to read and manipulate the population lookups#2

Closed
Moohan wants to merge 23 commits into
mainfrom
populations
Closed

Add function to read and manipulate the population lookups#2
Moohan wants to merge 23 commits into
mainfrom
populations

Conversation

@Moohan

@Moohan Moohan commented May 14, 2024

Copy link
Copy Markdown
Member

A handful of new functions for retrieving the population estimate files work like the others in that you can do:

get_hb_pop_est()
get_hscp_pop_est()
# etc

It will return the relevant populations file in a consistent long format as default, which is how the HB/HSCP/CA files are stored on disk but not how the DZ/IZ files are.

There is other optional functionality:

  • Group the data by age group: it uses phsmethods::create_age_groups() to create age groups so they can be customised using that function's parameters. The data will be returned aggregated to the age groups.
  • The data can also be pivoted to return the various population breakdowns (age/age group and sex) as columns instead of rows. There are a number of options for this to choose from different breakdowns.

@Moohan Moohan marked this pull request as ready for review June 20, 2024 17:13
@Moohan Moohan changed the title Populations Add function to read and manipulate the population lookups Jun 25, 2024
@Moohan Moohan linked an issue Jul 22, 2024 that may be closed by this pull request
@Moohan Moohan requested review from a team, Nic-Chr and nataliemcafee and removed request for a team October 7, 2024 11:46
@Moohan Moohan requested a review from Copilot September 2, 2025 16:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new function get_pop_est() to retrieve and manipulate population estimate lookups with flexible filtering and reshaping options.

  • Implements get_pop_est() function with support for different geographic levels, year filtering, age grouping, and data pivoting
  • Updates project configuration to use native pipe operator
  • Adds necessary package dependencies (janitor, phsmethods, tidyr)

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
R/get_pop_est.R New function implementation with comprehensive parameter validation and data transformation logic
man/get_pop_est.Rd Generated documentation with detailed examples and parameter descriptions
R/find_latest_file.R Enhanced to accept additional arguments for fs::dir_info()
DESCRIPTION Added new dependencies and version bump to development
NAMESPACE Exported the new function
NEWS.md Updated changelog with new feature
phslookups.Rproj Enabled native pipe operator

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread NEWS.md Outdated
Comment thread R/get_pop_est.R Outdated
Comment thread R/get_pop_est.R Outdated
Moohan and others added 2 commits October 2, 2025 12:21
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New lookup - Populations/Estimates

2 participants